package com.jp.knowledge.my.business;

import com.jp.knowledge.my.model.AuditModel;

import java.util.ArrayList;
import java.util.List;

/**
 * @author gzejia 978862664@qq.com
 */
public class AuditJoinBusiness {

    public List<AuditModel> getAudits() {
        String[] url = {
                "http://img2.imgtn.bdimg.com/it/u=65693088,620645654&fm=21&gp=0.jpg",
                "http://img4.imgtn.bdimg.com/it/u=3556354988,1632408036&fm=21&gp=0.jpg",
                "http://img4.imgtn.bdimg.com/it/u=1425972139,1057908849&fm=21&gp=0.jpg",
                "http://img5.imgtn.bdimg.com/it/u=3513715794,3905546937&fm=21&gp=0.jpg",
                "http://img2.imgtn.bdimg.com/it/u=1337071823,298452525&fm=21&gp=0.jpg",
                "http://img4.imgtn.bdimg.com/it/u=138599861,345053951&fm=21&gp=0.jpg",
                "http://img2.imgtn.bdimg.com/it/u=165474088,203424886&fm=21&gp=0.jpg",
                "http://img1.imgtn.bdimg.com/it/u=2305609775,202646090&fm=21&gp=0.jpg"};
        String[] name = {"林一", "刘二", "张三", "李四", "王五", "赵六", "黄七", "郭八"};
        String[] phone = {"13650702290", "15812254487", "13788565412", "19754844456", "13845455255",
                "15014223366", "13000254877", "19265669963"};
        String[] dateTime = {"2016-07-20 19:30", "2016-07-20 19:30", "2016-07-18 19:30",
                "2016-07-17 19:30", "2016-07-16 19:30", "2016-07-15 19:30", "2016-07-14 19:30",
                "2016-07-13 19:30"};
        int[] stats = {0, 0, 1, 1, 0, 2, 2, 0};

        List<AuditModel> models = new ArrayList<>();
        for (int i = 0, k = url.length; i < k; i++) {
            AuditModel model = new AuditModel();
            model.setName(name[i]);
            model.setUrl(url[i]);
            model.setPhone(phone[i]);
            model.setTime(dateTime[i]);
            model.setStats(stats[i]);
            models.add(model);
        }
        return models;
    }

    public static final int AUDIT_WAIT = 0;
    public static final int AUDIT_AGREE = 1;
    public static final int AUDIT_REFUSLE = 2;

    /**
     * @param list  审核内容集合
     * @param stats {@link #AUDIT_REFUSLE} 审核已拒绝；{@link #AUDIT_AGREE} 审核通过；{@link #AUDIT_AGREE} 待审核
     * @return 筛选结果集合
     */
    public List<AuditModel> getAuditByStats(List<AuditModel> list, int stats) {
        List<AuditModel> newModels = new ArrayList<>();

        for (AuditModel model : list) {
            if (model.getStats() == stats) {
                newModels.add(model);
            }
        }
        return newModels;
    }
}
